public class Demo49 {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable1 = new Runnable() {
            @Override
            public void run() {
                int i = 0;
                while(i<5){
                    System.out.println(Thread.currentThread().getName()+"在努力工作");
                    i++;
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println(Thread.currentThread().getName()+"工作完毕");
            }
        };
Thread t1 = new Thread(runnable1,"李华");
Thread t2 = new Thread(runnable1,"张三");
t1.start();//线程1启动
        t1.join();
        t2.start();
        t2.join();
        System.out.println("张三工作结束了");
    }
}
